<template>
  <el-dialog
    title="新增通知"
    :visible="showdialog"
    @close="btncancel"
  >
    <el-form :model="formData" :rules="rules" label-width="120px" >
      <el-form-item label="通知标题" prop="title" >
        <el-input v-model="formData.titl"  placeholder="请输入标题" />

      </el-form-item>
      <el-form-item label="消息类型" >
        <el-button >文本内容</el-button>
        <el-button>链接内容</el-button>
      </el-form-item>
      <el-form-item label="通知内容" prop="content" >
        <el-input v-model="formData.content"  type="textarea" :rows="3"/>
      </el-form-item>

      <el-form-item label="发送全部">
        <el-switch

          active-color="#13ce66"
          inactive-color="#ff4949"
        />
      </el-form-item>
      <el-form-item label="所属小区" prop="shequ">
        <el-select v-model="formData.send" placeholder="请选择">
          <el-option v-model="formData.shequ" value="shequ" />
        </el-select>
      </el-form-item>

    </el-form>
    <el-row slot="footer" type="flex" justify="center">
      <!-- 列被分为24 -->
      <el-col :span="6">
        <el-button type="primary" size="small" @click="btnok">确定</el-button>
        <el-button size="small" @click="btncancel">取消</el-button>
      </el-col>
    </el-row>

  </el-dialog>
</template>
<script>
import { getxiaoqulist } from "@/api/qianqian"

export default {

  props: {
    showdialog: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      shequ: '', // 存储输入框的值
      formData: {
        titl: '',
        content: '',
        shequ: ''

      },
      rules:{
        title: [{ trigger: 'blur', message: '标题不能为空',  required: true,}] ,
        content: [{ trigger: 'blur', message: '通知内容不能为空',  required: true,}
        ] ,
        shequ:[{ trigger: 'change', message: '通知内容不能为空',  required: true,}
        ] ,

      }
     

    }
  },
  created(){
    this.getxiaoqulist()
  },
 
  methods: {
    // 获取小区
   async getxiaoqulist(){
    try{
      const data= await getxiaoqulist()
      this.shequ=data[0].communityName
    console.log(data);

    }catch(err){
      console.log(err);
    }
    

    },

    btnok() {
     

      },
       btncancel() {
      // 把属性和值传给父组件关闭弹层
      this.$emit('update', false)
    }

    },
   

  }

</script>
  <style >
  </style >
